<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="btn" uri="http://www.dsdl.com/dev/jsp/btn" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<%@include file="../base/base.jspf" %>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">

            <div class="layui-form-item">
                <input type="hidden" name="agmId" value="${agreement.agmId}"/>

                <blockquote class="layui-elem-quote" style="margin-top:10px;">温馨提示: 此处配置用户协议
                </blockquote>

                <div class="layui-input-block">
                    <textarea name="agmUserAgreement" id="informSubmitPage-userAgEdit" style="width: 90%; height: 500px;"
                              autocomplete="off"
                              class="layui-textarea" type="text/plain">
                        ${agreement.agmUserAgreement}
                    </textarea>
                    <btn:btn btnStr="userAgEdit">
                        <button class="layui-btn" lay-submit lay-filter="useragedit">保存用户协议</button>
                    </btn:btn>
                </div>

            </div>
        </div>


        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <input type="hidden" name="agmId" value="${agreement.agmId}"/>
                <blockquote class="layui-elem-quote" style="margin-top:10px;">温馨提示: 此处配置隐私政策
                </blockquote>
                <div class="layui-input-block">
                <textarea name="agmPrivacyAgreement" id="informSubmitPage-privacy" style="width: 90%; height: 500px;"
                          autocomplete="off"
                          class="layui-textarea" type="text/plain">
                    ${agreement.agmPrivacyAgreement}
                </textarea>
                    <btn:btn btnStr="privacyEdit">
                        <button class="layui-btn" lay-submit lay-filter="privacy">保存隐私政策</button>
                    </btn:btn>
                </div>
            </div>

        </div>
    </div>
</div>


<script type="text/javascript">


    var ueditor
    $(function () {
        UE.delEditor('informSubmitPage-userAgEdit');
        ueditor = UE.getEditor('informSubmitPage-userAgEdit', {
            autoFloatEnabled: false,//是否保持toolbar位置不懂，默认为true
            autoHeightEnabled: false,//固定高度
            initialFrameHeight: 500
        });
    })


    var ueditor1
    $(function () {
        UE.delEditor('informSubmitPage-privacy');
        ueditor1 = UE.getEditor('informSubmitPage-privacy', {
            autoFloatEnabled: false,//是否保持toolbar位置不懂，默认为true
            autoHeightEnabled: false,//固定高度
            initialFrameHeight: 500
        });
    })

    layui.config({
        base: "${ctx}/static/framework/layuiadmin/" //静态资源所在路径
    }).extend({
        index: "lib/index" //主入口模块
    }).use(["index", "table", "form"], function () {
        var table = layui.table,
            form = layui.form;

        form.on('submit(useragedit)', function (data) {
            var content1 = ueditor.getContent();
            $.ajax({
                async: true,
                url: "${ctx}/agreement/agreementSubmit",
                type: "post",
                dataType: "json",
                data: {
                    agmId: data.field.agmId,
                    agmUserAgreement: content1
                },
                success: function (data) {
                    if (data.result) {
                        layer.msg(data.info);
                    } else {
                        error(data.info);
                    }
                }
            });
            return false;
        });

        form.on('submit(privacy)', function (data) {
            var content2 = ueditor1.getContent();
            $.ajax({
                async: true,
                url: "${ctx}/agreement/agreementSubmit",
                type: "post",
                dataType: "json",
                data: {
                    agmId: data.field.agmId,
                    agmPrivacyAgreement: content2
                },
                success: function (data) {

                    if (data.result) {
                        layer.msg(data.info);
                    } else {
                        error(data.info);
                    }
                }
            });
        });

    });
</script>